import React, { PureComponent } from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { BrowserRouter, Switch, Route } from 'react-router-dom'

import { connectWs, disconnectWs } from '../redux/actions/appAction'

import Trade from './trade/Trade'

@connect(() => {
  return {}
}, (dispatch) => {
  return bindActionCreators({
    connectWs, disconnectWs
  }, dispatch)
})
class App extends PureComponent {
  componentDidMount () {
    this.props.connectWs()
  }

  componentWillUnmount () {
    this.props.disconnectWs()
  }

  render () {
    return (
      <BrowserRouter>
        <Switch>
          <Route component={Trade}/>
        </Switch>
      </BrowserRouter>
    )
  }
}

export default App
